package cn.com.chinahitech.bjmarket.pie.controller;


import cn.com.chinahitech.bjmarket.pie.entity.Pie;
import cn.com.chinahitech.bjmarket.pie.service.IPieService;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhufu
 * @since 2020-07-07
 */
@Controller
@CrossOrigin
@RequestMapping("/pie/")
@Api(value="Pie信息接口",tags = {"Pie信息的Controller"})
public class PieController {
    @Autowired
    private IPieService pieService;

    @RequestMapping(value="/cityData",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value="检索城市列表数据",notes = "城市大数据工作岗位查询接口")
    public String getCityData(){
        Map<String,Object> map = new HashMap<String,Object>();
        try{
           List<Pie> pieList =pieService.getCityData();
           map.put("status","200");
           map.put("data",pieList);
        }catch(Exception ex){
            map.put("status","-1");
            map.put("data",ex.getMessage());
        }
        return JSON.toJSONString(map);
    }

    @RequestMapping("/show")
    @ApiIgnore
    public String showPie(){
        return "pie";
    }

}
